﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：WTB_FAPIAOXX实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class WTB_FAPIAOXX
    {

        private int m_dec_id;
        /// <summary>
        /// 唯一约束，禁止关联
        /// </summary>
        public int ID { get { return m_dec_id; } set { m_dec_id = value; } }

        private string m_str_s_zhubiaobh;
        /// <summary>
        /// 主表编号，关联主表
        /// </summary>
        public string S_ZHUBIAOBH { get { return m_str_s_zhubiaobh; } set { m_str_s_zhubiaobh = value; } }

        private string m_str_incident_id;
        /// <summary>
        /// 申请单唯一ID
        /// </summary>
        public string INCIDENT_ID { get { return m_str_incident_id; } set { m_str_incident_id = value; } }

        private string m_str_notice_type;
        /// <summary>
        /// 补缴费通知单类型 0：纸质（默认）；1：电子
        /// </summary>
        public string NOTICE_TYPE { get { return m_str_notice_type; } set { m_str_notice_type = value; } }

        private string m_str_contact_invoice;
        /// <summary>
        /// 发票电话号码
        /// </summary>
        public string CONTACT_INVOICE { get { return m_str_contact_invoice; } set { m_str_contact_invoice = value; } }

        private string m_str_social_credit_code;
        /// <summary>
        /// 纳税人识别号,企业：纳税人识别号；个人：为空
        /// </summary>
        public string SOCIAL_CREDIT_CODE { get { return m_str_social_credit_code; } set { m_str_social_credit_code = value; } }

        private string m_str_apply_type;
        /// <summary>
        /// 申请类型(	电子发票自动推送) 1-申请；2-修改；3-取消
        /// </summary>
        public string APPLY_TYPE { get { return m_str_apply_type; } set { m_str_apply_type = value; } }

        private string m_str_user_name;
        /// <summary>
        /// 户名
        /// </summary>
        public string USER_NAME { get { return m_str_user_name; } set { m_str_user_name = value; } }

        private string m_str_bill_month;
        /// <summary>
        /// 账单年月
        /// </summary>
        public string BILL_MONTH { get { return m_str_bill_month; } set { m_str_bill_month = value; } }

        private string m_str_money;
        /// <summary>
        /// 账单金额
        /// </summary>
        public string MONEY { get { return m_str_money; } set { m_str_money = value; } }

        private string m_str_post_address;
        /// <summary>
        /// 注册地址
        /// </summary>
        public string POST_ADDRESS { get { return m_str_post_address; } set { m_str_post_address = value; } }

        private string m_str_company_name;
        /// <summary>
        /// 企业名称
        /// </summary>
        public string COMPANY_NAME { get { return m_str_company_name; } set { m_str_company_name = value; } }

        private string m_str_fptt;
        /// <summary>
        /// 发票抬头
        /// </summary>
        public string FPTT { get { return m_str_fptt; } set { m_str_fptt = value; } }

        private string m_str_open_bank;
        /// <summary>
        /// 开户行
        /// </summary>
        public string OPEN_BANK { get { return m_str_open_bank; } set { m_str_open_bank = value; } }

        private string m_str_bank_card_no;
        /// <summary>
        /// 银行卡号
        /// </summary>
        public string BANK_CARD_NO { get { return m_str_bank_card_no; } set { m_str_bank_card_no = value; } }

        private string m_str_s_beiyong1;
        /// <summary>
        /// 
        /// </summary>
        public string S_BEIYONG1 { get { return m_str_s_beiyong1; } set { m_str_s_beiyong1 = value; } }

        private string m_str_s_beiyong2;
        /// <summary>
        /// 
        /// </summary>
        public string S_BEIYONG2 { get { return m_str_s_beiyong2; } set { m_str_s_beiyong2 = value; } }

        private string m_str_s_beiyong3;
        /// <summary>
        /// 
        /// </summary>
        public string S_BEIYONG3 { get { return m_str_s_beiyong3; } set { m_str_s_beiyong3 = value; } }
        public WTB_FAPIAOXX()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace Access.BLL
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class WTB_FAPIAOXXProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public WTB_FAPIAOXXProcess() { conn = Platform.Configuration.ConfigHelper.BusinessConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据WTB_FAPIAOXX实体添加或者修改WTB_FAPIAOXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_FAPIAOXX WTB_FAPIAOXX, OracleTransaction Transaction)
        {
            if (WTB_FAPIAOXX.ID == 0)
            {
                InsertWTB_FAPIAOXX(WTB_FAPIAOXX, Transaction);
            }
            else
            {
                UpdateWTB_FAPIAOXX(WTB_FAPIAOXX, Transaction);
            }
            return WTB_FAPIAOXX.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_FAPIAOXX实体添加或修改WTB_FAPIAOXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_FAPIAOXX WTB_FAPIAOXX)
        {
            return InsertOrUpdate(WTB_FAPIAOXX, null);
        }



        /// <summary>
        /// 根据WTB_FAPIAOXX主键删除WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_FAPIAOXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_FAPIAOXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_FAPIAOXX主键删除WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_FAPIAOXX(int ID)
        {
            return DeleteWTB_FAPIAOXX(ID, null);
        }

        /// <summary>
        /// 根据条件删除WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_FAPIAOXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_FAPIAOXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_FAPIAOXXesDynamic(string WhereClause)
        {
            return DeleteWTB_FAPIAOXXesDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据WTB_FAPIAOXX主键选择WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_FAPIAOXX信息</returns>
        public WTB_FAPIAOXX SelectWTB_FAPIAOXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_FAPIAOXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                WTB_FAPIAOXX WTB_FAPIAOXX = PopulateWTB_FAPIAOXX(rd);
                rd.Close();
                return WTB_FAPIAOXX;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据WTB_FAPIAOXX主键选择WTB_FAPIAOXX信息
        /// </summary>
        /// <returns>WTB_FAPIAOXX信息</returns>
        public WTB_FAPIAOXX SelectWTB_FAPIAOXX(int ID)
        {
            return SelectWTB_FAPIAOXX(ID, null);
        }

        /// <summary>
        /// 选择所有WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有WTB_FAPIAOXX信息</returns>
        public DataTable SelectWTB_FAPIAOXXesAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_FAPIAOXXesAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有WTB_FAPIAOXX信息
        /// </summary>
        /// <returns>所有WTB_FAPIAOXX信息</returns>
        public DataTable SelectWTB_FAPIAOXXesAll()
        {
            return SelectWTB_FAPIAOXXesAll(null);
        }

        /// <summary>
        /// 根据条件选择WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_FAPIAOXX信息</returns>
        public DataTable SelectWTB_FAPIAOXXesDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_FAPIAOXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>WTB_FAPIAOXX信息</returns>
        public DataTable SelectWTB_FAPIAOXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectWTB_FAPIAOXXesDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_FAPIAOXX信息</returns>
        public DataTable SelectWTB_FAPIAOXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_FAPIAOXXesDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_FAPIAOXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>WTB_FAPIAOXX信息</returns>
        public DataTable SelectWTB_FAPIAOXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectWTB_FAPIAOXXesDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新WTB_FAPIAOXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_FAPIAOXXesDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdWTB_FAPIAOXXDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新WTB_FAPIAOXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_FAPIAOXXesDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateWTB_FAPIAOXXesDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertWTB_FAPIAOXX(WTB_FAPIAOXX WTB_FAPIAOXX, OracleTransaction Transaction)
        {
            string spName = "CS_InsWTB_FAPIAOXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_FAPIAOXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_FAPIAOXX.INCIDENT_ID;
            storedParams[2].Value = WTB_FAPIAOXX.NOTICE_TYPE;
            storedParams[3].Value = WTB_FAPIAOXX.CONTACT_INVOICE;
            storedParams[4].Value = WTB_FAPIAOXX.SOCIAL_CREDIT_CODE;
            storedParams[5].Value = WTB_FAPIAOXX.APPLY_TYPE;
            storedParams[6].Value = WTB_FAPIAOXX.USER_NAME;
            storedParams[7].Value = WTB_FAPIAOXX.BILL_MONTH;
            storedParams[8].Value = WTB_FAPIAOXX.MONEY;
            storedParams[9].Value = WTB_FAPIAOXX.POST_ADDRESS;
            storedParams[10].Value = WTB_FAPIAOXX.COMPANY_NAME;
            storedParams[11].Value = WTB_FAPIAOXX.FPTT;
            storedParams[12].Value = WTB_FAPIAOXX.OPEN_BANK;
            storedParams[13].Value = WTB_FAPIAOXX.BANK_CARD_NO;
            storedParams[14].Value = WTB_FAPIAOXX.S_BEIYONG1;
            storedParams[15].Value = WTB_FAPIAOXX.S_BEIYONG2;
            storedParams[16].Value = WTB_FAPIAOXX.S_BEIYONG3;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            WTB_FAPIAOXX.ID = Convert.ToInt32(storedParams[17].Value);
            return result;
        }
        private bool UpdateWTB_FAPIAOXX(WTB_FAPIAOXX WTB_FAPIAOXX, OracleTransaction Transaction)
        {
            string spName = "CS_UpdWTB_FAPIAOXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_FAPIAOXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_FAPIAOXX.INCIDENT_ID;
            storedParams[2].Value = WTB_FAPIAOXX.NOTICE_TYPE;
            storedParams[3].Value = WTB_FAPIAOXX.CONTACT_INVOICE;
            storedParams[4].Value = WTB_FAPIAOXX.SOCIAL_CREDIT_CODE;
            storedParams[5].Value = WTB_FAPIAOXX.APPLY_TYPE;
            storedParams[6].Value = WTB_FAPIAOXX.USER_NAME;
            storedParams[7].Value = WTB_FAPIAOXX.BILL_MONTH;
            storedParams[8].Value = WTB_FAPIAOXX.MONEY;
            storedParams[9].Value = WTB_FAPIAOXX.POST_ADDRESS;
            storedParams[10].Value = WTB_FAPIAOXX.COMPANY_NAME;
            storedParams[11].Value = WTB_FAPIAOXX.FPTT;
            storedParams[12].Value = WTB_FAPIAOXX.OPEN_BANK;
            storedParams[13].Value = WTB_FAPIAOXX.BANK_CARD_NO;
            storedParams[14].Value = WTB_FAPIAOXX.S_BEIYONG1;
            storedParams[15].Value = WTB_FAPIAOXX.S_BEIYONG2;
            storedParams[16].Value = WTB_FAPIAOXX.S_BEIYONG3;
            storedParams[17].Value = WTB_FAPIAOXX.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private WTB_FAPIAOXX PopulateWTB_FAPIAOXX(IDataReader dr)
        {
            WTB_FAPIAOXX WTB_FAPIAOXX = new WTB_FAPIAOXX();
            WTB_FAPIAOXX.ID = Convert.ToInt32(dr["ID"].ToString());
            WTB_FAPIAOXX.S_ZHUBIAOBH = dr["S_ZHUBIAOBH"] == DBNull.Value ? null : (string)dr["S_ZHUBIAOBH"];
            WTB_FAPIAOXX.INCIDENT_ID = dr["INCIDENT_ID"] == DBNull.Value ? null : (string)dr["INCIDENT_ID"];
            WTB_FAPIAOXX.NOTICE_TYPE = dr["NOTICE_TYPE"] == DBNull.Value ? null : (string)dr["NOTICE_TYPE"];
            WTB_FAPIAOXX.CONTACT_INVOICE = dr["CONTACT_INVOICE"] == DBNull.Value ? null : (string)dr["CONTACT_INVOICE"];
            WTB_FAPIAOXX.SOCIAL_CREDIT_CODE = dr["SOCIAL_CREDIT_CODE"] == DBNull.Value ? null : (string)dr["SOCIAL_CREDIT_CODE"];
            WTB_FAPIAOXX.APPLY_TYPE = dr["APPLY_TYPE"] == DBNull.Value ? null : (string)dr["APPLY_TYPE"];
            WTB_FAPIAOXX.USER_NAME = dr["USER_NAME"] == DBNull.Value ? null : (string)dr["USER_NAME"];
            WTB_FAPIAOXX.BILL_MONTH = dr["BILL_MONTH"] == DBNull.Value ? null : (string)dr["BILL_MONTH"];
            WTB_FAPIAOXX.MONEY = dr["MONEY"] == DBNull.Value ? null : (string)dr["MONEY"];
            WTB_FAPIAOXX.POST_ADDRESS = dr["POST_ADDRESS"] == DBNull.Value ? null : (string)dr["POST_ADDRESS"];
            WTB_FAPIAOXX.COMPANY_NAME = dr["COMPANY_NAME"] == DBNull.Value ? null : (string)dr["COMPANY_NAME"];
            WTB_FAPIAOXX.FPTT = dr["FPTT"] == DBNull.Value ? null : (string)dr["FPTT"];
            WTB_FAPIAOXX.OPEN_BANK = dr["OPEN_BANK"] == DBNull.Value ? null : (string)dr["OPEN_BANK"];
            WTB_FAPIAOXX.BANK_CARD_NO = dr["BANK_CARD_NO"] == DBNull.Value ? null : (string)dr["BANK_CARD_NO"];
            WTB_FAPIAOXX.S_BEIYONG1 = dr["S_BEIYONG1"] == DBNull.Value ? null : (string)dr["S_BEIYONG1"];
            WTB_FAPIAOXX.S_BEIYONG2 = dr["S_BEIYONG2"] == DBNull.Value ? null : (string)dr["S_BEIYONG2"];
            WTB_FAPIAOXX.S_BEIYONG3 = dr["S_BEIYONG3"] == DBNull.Value ? null : (string)dr["S_BEIYONG3"];
            return WTB_FAPIAOXX;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion